package com.iteaj.iot.test.serial;

import com.fazecast.jSerialComm.SerialPort;
import com.iteaj.iot.serial.SerialComponent;
import com.iteaj.iot.serial.SerialPortBuilder;
import com.iteaj.iot.test.IotTestHandle;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnExpression("${iot.test.serial-start:false}")
public class SerialTestHandle implements IotTestHandle {

    @Override
    public void start() throws Exception {
        System.out.println("------------------------------------------------------ 开始串口测试 ---------------------------------------------");
        SerialPort[] available = SerialComponent.instance().available();
        SerialPort serialPort = SerialPortBuilder.open("com1");
        System.out.println(available);
    }

    @Override
    public int getOrder() {
        return 5500;
    }
}
